#pragma once

#include <MyFC/Control.h>
#include "ListControl.h"
#include "Property.h"

namespace My {

class PEditor;
class PropertyList;

class PropertyRow : public RowControl, public Container {
private:
	PEditor &					m_Editor;
	PropertyList &				m_List;
	String						m_Caption;
	PropertyBase *				m_pProperty;
	const EditableList &		m_Objects;
	EditableList				m_SubObjects;
	const PropertyMap *			m_pSubProperties;
	Widget *					m_pControl;
	PropertyRow *				m_pParent;
	std::vector<RowControl *>	m_Children;
	bool						m_Expanded;
	bool						m_Valid;
	CRect						m_ButtonRect;
private:
	void CreateChildren(const PropertyMap &	map, const EditableList &);
public:
	PropertyRow(PEditor & e, const String & s, PropertyBase * pProperty, const EditableList &, PropertyRow * pParent = 0);
	~PropertyRow();
public:
	PropertyBase * GetProperty() const
		{ return m_pProperty; }
	bool IsExpandable() const;
	bool IsExpanded() const
		{ return m_Expanded; }
	int GetLevel() const;
	void Expand();
	void Collapse();
	int GetDefaultRowHeight() const;
	void Update();
public:
	virtual bool Enabled() const;
	virtual void LayoutControls();
	virtual void HandlePaint(CDC * pDC, const CRect & r);
	virtual void HandleLeftDoubleClick(unsigned int flags, const CPoint & p);
	virtual void HandleLeftDown(unsigned int flags, const CPoint & p);
	virtual void ProcessEvent(Event &);
	virtual void HandleUpdateUI();
};

} // My